home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / winsock / ircii2-6.zip / SRC\IRCII-2.6\SOURCE\OUTPUT.C < prev    next >
C/C++ Source or Header  |  1994-12-29  |  5KB  |  241 lines

  1. /*
  2.  * output.c: handles a variety of tasks dealing with the output from the irc
  3.  * program 
  4.  *
  5.  * Written By Michael Sandrof
  6.  *
  7.  * Copyright(c) 1990 
  8.  *
  9.  * See the COPYRIGHT file, or do a HELP IRCII COPYRIGHT 
  10.  */
  11.  
  12. #ifndef lint
  13. static    char    rcsid[] = "@(#)$Id: output.c,v 1.9 1994/10/08 13:50:20 mrg Stab $";
  14. #endif
  15.  
  16. #include "irc.h"
  17.  
  18. #include <sys/ioctl.h>
  19.  
  20. #include "output.h"
  21. #include "vars.h"
  22. #include "input.h"
  23. #include "term.h"
  24. #include "lastlog.h"
  25. #include "window.h"
  26. #include "screen.h"
  27. #include "hook.h"
  28. #include "ctcp.h"
  29. #include "log.h"
  30.  
  31.     int    in_help = 0;
  32.  
  33. /* make this buffer *much* bigger than needed */
  34. static    char    FAR putbuf[BIG_BUFFER_SIZE + 1] = "";
  35.  
  36. /*
  37.  * refresh_screen: Whenever the REFRESH_SCREEN function is activated, this
  38.  * swoops into effect 
  39.  */
  40. /*ARGSUSED*/
  41. RETSIGTYPE    refresh_screen(key, ptr)
  42. char    *key;
  43. void    (*ptr)();
  44. {
  45.     term_clear_screen();
  46.     if (term_resize())
  47.         recalculate_windows();
  48.     else
  49.         redraw_all_windows();
  50.     update_all_windows();
  51.     update_input(UPDATE_ALL);
  52. }
  53.  
  54. /* init_windows:  */
  55. void    init_screen()
  56. {
  57.     term_init();
  58.     term_clear_screen();
  59.     term_resize();
  60.     new_window();
  61.     recalculate_windows();
  62.     update_all_windows();
  63.     init_input();
  64.     term_move_cursor(0, 0);
  65. }
  66.  
  67. /* put_file: uses put_it() to display the contents of a file to the display */
  68. void    put_file(filename)
  69. char    *filename;
  70. {
  71.     FILE    *fp;
  72.     char    line[256];        /* too big?  too small?  who cares? */
  73.     int    len;
  74.  
  75.     if ((fp = fopen(filename, "r")) != (FILE *) 0)
  76.     {
  77.         while (fgets(line, 256, fp))
  78.         {
  79.             len = strlen(line);
  80.             if (*(line + len - 1) == '\n')
  81.                 *(line + len - 1) = (char) 0;
  82.             put_it("%s", line);
  83.         }
  84.         fclose(fp);
  85.     }
  86. }
  87.  
  88. /*
  89.  * put_it: the irc display routine.  Use this routine to display anything to
  90.  * the main irc window.  It handles sending text to the display or stdout as
  91.  * needed, add stuff to the lastlog and log file, etc.  Things NOT to do:
  92.  * Dont send any text that contains \n, very unpredictable.  Tabs will also
  93.  * screw things up.  The calling routing is responsible for not overwriting
  94.  * the 1K buffer allocated.  
  95.  *
  96.  * For Ultrix machines, you can't call put_it() with floating point arguements.
  97.  * It just doesn't work.  - phone, jan 1993.
  98.  */
  99. /*VARARGS*/
  100. #ifdef USE_STDARG_H
  101. void    put_it(char *format, ...)
  102. {
  103.     va_list vl;
  104. #else
  105. void    put_it(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
  106. char    *format;
  107. char    *arg1,
  108.     *arg2,
  109.     *arg3,
  110.     *arg4,
  111.     *arg5,
  112.     *arg6,
  113.     *arg7,
  114.     *arg8,
  115.     *arg9,
  116.     *arg10;
  117. {
  118. #endif
  119.     if (window_display)
  120.     {
  121. #ifdef USE_STDARG_H
  122.         va_start(vl, format);
  123.         vsprintf(putbuf, format, vl);
  124.         va_end(vl);
  125. #else
  126.         sprintf(putbuf, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
  127. #endif
  128.         add_to_log(irclog_fp, putbuf);
  129.         add_to_screen(putbuf);
  130.     }
  131. }
  132.  
  133. /* This is an alternative form of put_it which writes three asterisks
  134.  * before actually putting things out.
  135.  */
  136. #ifdef USE_STDARG_H
  137. void    say(char *format, ...)
  138. {
  139.     va_list vl;
  140. #else
  141. void    say(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
  142. char    *format;
  143. char    *arg1,
  144.     *arg2,
  145.     *arg3,
  146.     *arg4,
  147.     *arg5,
  148.     *arg6,
  149.     *arg7,
  150.     *arg8,
  151.     *arg9,
  152.     *arg10;
  153. {
  154. #endif
  155.     if (window_display)
  156.     {
  157.         putbuf[0] = putbuf[1] = putbuf[2] = '*';
  158.         putbuf[3] = ' ';
  159. #ifdef USE_STDARG_H
  160.         va_start(vl, format);
  161.         vsprintf(&putbuf[4], format, vl);
  162.         va_end(vl);
  163. #else
  164.         sprintf(&putbuf[4], format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
  165. #endif
  166.         add_to_log(irclog_fp, putbuf);
  167.         add_to_screen(putbuf);
  168.     }
  169. }
  170.  
  171. #ifdef USE_STDARG_H
  172. void    yell(char *format, ...)
  173. {
  174.     va_list vl;
  175. #else
  176. void    yell(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
  177. char    *format;
  178. char    *arg1,
  179.     *arg2,
  180.     *arg3,
  181.     *arg4,
  182.     *arg5,
  183.     *arg6,
  184.     *arg7,
  185.     *arg8,
  186.     *arg9,
  187.     *arg10;
  188. {
  189. #endif
  190. #ifdef USE_STDARG_H
  191.     va_start(vl, format);
  192.     vsprintf(putbuf, format, vl);
  193.     va_end(vl);
  194. #else
  195.     sprintf(putbuf, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
  196. #endif
  197.     add_to_log(irclog_fp, putbuf);
  198.     add_to_screen(putbuf);
  199. }
  200.  
  201.  
  202. /* help_put_it: works just like put_it, but is specially used by help */
  203. #ifdef USE_STDARG_H
  204. void    help_put_it(char *topic, char *format, ...)
  205. {
  206.     va_list vl;
  207. #else
  208. void    help_put_it(topic, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
  209. char    *format,
  210.     *topic;
  211. char    *arg1,
  212.     *arg2,
  213.     *arg3,
  214.     *arg4,
  215.     *arg5,
  216.     *arg6,
  217.     *arg7,
  218.     *arg8,
  219.     *arg9,
  220.     *arg10;
  221. {
  222. #endif
  223. #ifdef USE_STDARG_H
  224.     va_start(vl, format);
  225.     vsprintf(putbuf, format, vl);
  226.     va_end(vl);
  227. #else
  228.     sprintf(putbuf, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
  229. #endif
  230.     in_help = 1;
  231.     if (do_hook(HELP_LIST, "%s %s", topic, putbuf))
  232.     {
  233.         if (window_display)
  234.         {
  235.             add_to_log(irclog_fp, putbuf);
  236.             add_to_screen(putbuf);
  237.         }
  238.     }
  239.     in_help = 0;
  240. }
  241.